/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 *
 * @author: jin Chen 
 * @date: Jun 24, 2003
 * @version: $VERSION$
 */
package edu.psu.geovista.app.plot.axis;

import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;

public class ThumbList extends Hashtable {
    public HashSet getThumbsWithTypeOf(int type){
        HashSet thumbs=new HashSet();
        Iterator iter=this.iterator() ;
        while(iter.hasNext() ){
             Thumb tb=(Thumb)iter.next() ;
             if (tb.getType() ==type){
                 thumbs.add(tb);
             }

        }

        return thumbs;
    }
    public Range getExtremeOfType(int type){
         HashSet tmbs=this.getThumbsWithTypeOf(type);
         Object[] vs=tmbs.toArray() ;
         float v0=((Thumb)vs[0]).getValue();
         float v1=((Thumb)vs[1]).getValue();

         //float[] vs
         if(vs.length >2){
             System.out.println(" out of design ");
         }
         float max=Math.max(v0,v1);
         float min=Math.min(v0,v1);


         Range ex=new Range(0,0);
         ex.setMax(max);
         ex.setMin(min);
        /*
         Iterator iter=tmbs.iterator() ;
         while(iter.hasNext() ){
              Thumb tb=(Thumb)iter.next() ;

              if(value >ex.getMax() ){
                  ex.setMax(value );
              }
              else if(value<ex.getMin() ){
                  ex.setMin(value);
              }
         }
        Math.*/
        return ex;
    }



    public Iterator iterator() {
         return this.values().iterator() ;
     }
}
